// 找回密码选项卡
$('.pr-form-title span').on('touchend click', function (e) {
    e.preventDefault();
    $(this).addClass('pr-ft-this').siblings().removeClass('pr-ft-this');
    var index = $(this).index();
    $('.pr-form-main ul').eq(index).addClass('fff').show().siblings('ul').removeClass('fff').hide()
}).eq(0).click();

/*
 // 表单验证
 //获得/失去焦点样式
 $('.pr-form-main input').focus(function () {
 $(this).css({borderColor: "#35a2ff"})
 }).blur(function () {
 $(this).css({borderColor: ""})
 });

 $('#tel').blur(function () {
 var rule = /^[1][34578][\d]{9}$/.test($('#tel').val());
 if (rule) {
 $(this).removeClass('error').next($('.u-ts')).html('')
 } else {
 $(this).addClass('error').next($('.u-ts')).html('<i class="iconfont icon-cuowu"></i>&nbsp;请输入正确手机号')
 }
 });

 $('.yzm').blur(function () {
 var rule = $('.yzm').val();
 if (rule) {
 $(this).removeClass('error').siblings('.u-ts').html('')
 } else {
 $(this).addClass('error').siblings('.u-ts').html('<i class="iconfont icon-cuowu"></i>&nbsp;请输入正确验证码')
 }
 });

 $('#telyzm,#emailyzm').blur(function () {
 var rule = $('#telyzm').val() || $('#emailyzm').val();
 if (rule) {
 $(this).removeClass('error').siblings('.u-ts').html('')
 } else {
 $(this).addClass('error').siblings('.u-ts').html('<i class="iconfont icon-cuowu"></i>&nbsp;请输入正确验证码')
 }
 });

 $('.setmm').blur(function () {
 var rule = /^[a-z0-9_-]{6,18}$/.test($('.setmm').val());
 if (rule) {
 $(this).removeClass('error').next($('.u-ts')).html('')
 } else {
 $(this).addClass('error').next($('.u-ts')).html('<i class="iconfont icon-cuowu"></i>&nbsp;请输入6-18位字母，数字，-')
 }
 });

 $('.prmm').blur(function () {
 var setmm = $('.setmm').val();
 var prmm = $('.prmm').val();
 if (setmm === prmm && prmm) {
 $(this).removeClass('error').next($('.u-ts')).html('')
 } else {
 $(this).addClass('error').next($('.u-ts')).html('<i class="iconfont icon-cuowu"></i>&nbsp;两次密码输入不一致')
 }
 });

 $('.getTelYzm').on('touchend click', function (e) {
 e.preventDefault();
 var rule = /^1(3|4|5|7|8)\d{9}$/.test($('.tel').val()) || /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/.test($('.email').val());
 var suc = !$('.yzm').hasClass('error');
 var wfs = !$(this).hasClass('yfs');
 if (rule && suc && wfs) {
 var num = 60, timer;
 $(this).addClass('yfs').val('重新发送（' + num + '）');
 timer = setInterval(function () {
 num--;
 $('.getTelYzm').addClass('yfs').val('重新发送（' + num + '）');
 if (num <= 0) {
 clearInterval(timer);
 $('.getTelYzm').removeClass('yfs').val('获取验证码');
 }
 }, 1000);
 }
 });

 $('.pr-form-submit button').on('touchend click', function (e) {
 e.preventDefault();
 $('.pr-form-main input').blur();
 var error = $('.pr-form-main input').hasClass('error');
 if (error) {
 $('.error').eq(0).focus()
 } else {
 // 提交
 $('.xg-cg').show();
 setTimeout(function () {
 $('.xg-cg').hide();
 }, 1200)
 }
 });
 */

// 验证规则
$('#backForm').validate({
    rules: {
        tel: {
            required: true,
            telNum: true
        },
        sj_yzm: {
            required: true
        },
        telyzm: {
            required: true
        },
        setmm: {
            required: true,
            password:true
        },
        prmm: {
            required: true,
            equalTo: '#setmm'
        },
        email:{
            required: true,
            email:true
        },
        yx_yzm:{
            required: true
        },
        emailyzm:{
            required: true
        },
        yx_setmm:{
            required: true,
            password:true
        },
        yx_prmm:{
            required: true,
            equalTo: '#yx-prmm'
        }
    },
    messages: {
        tel: {
            required: "不能为空"
        },
        sj_yzm: {
            required: "不能为空"
        },
        telyzm: {
            required: "不能为空"
        },
        setmm: {
            required: "不能为空",
        },
        prmm: {
            required: "不能为空",
            equalTo:"两次输入密码不一致"
        },
        email:{
            required: "请输入绑定邮箱",
            email:"请输入正确的邮箱"
        },
        yx_yzm:{
            required: "不能为空"
        },
        emailyzm:{
            required: "不能为空"
        },
        yx_setmm:{
            required: "不能为空"
        },
        yx_prmm:{
            required: "不能为空",
            equalTo: '两次输入密码不一致'
        }
    },
    errorPlacement: function (error, element) {
        $(element).siblings('.u-ts').html(error)
    },
    errorElement: 'span',
    submitHandler: function (form) {
        form.submit();
    }
});

jQuery.validator.addMethod('telNum', function (value, element) {
    var phoneNum = /^[1][34578][\d]{9}$/.test(value);
    return this.optional(element) || phoneNum
}, '请输入正确手机号');

jQuery.validator.addMethod('password', function (value, element) {
    var password = /^[a-z0-9_-]{6,18}$/.test(value);
    return this.optional(element) || password
}, '请输入6-18位字母，数字_-');

